import i18n from '@app-base/common/utils/i18next';
import {
  ENTITY_TYPE_EDGE,
  ENTITY_TYPE_FACE,
  ENTITY_TYPE_VOLUME,
  NMMeshBaseCommand,
} from '@app-nextmesh/types';
import { RJSFSchema } from '@rjsf/utils';
import { NameSchema, SelectedEntitiesSchema, SizeSchema } from '../jsonSchema';
import CmdControlDialog from './BaseControl';

const ControlType = 'MeshSize';
const schema: RJSFSchema = {
  type: 'object',
  required: ['Name', 'SelectedEntities'],
  properties: {
    ...NameSchema,
    ...SizeSchema,
    ...SelectedEntitiesSchema,
  },
};
export const cmdMeshSize: NMMeshBaseCommand = {
  id: 'cmdMeshSize',
  label: 'command.mesh.size',
  icon: 'commands/simu/mesh-size',
  create: (label, onClose, _, customParams) => (
    <CmdControlDialog
      title={i18n.t(label)}
      onClose={onClose}
      params={customParams}
      pickTypes={[ENTITY_TYPE_EDGE, ENTITY_TYPE_FACE, ENTITY_TYPE_VOLUME]}
      controlType={ControlType}
      schema={schema}
    />
  ),
};
